﻿using Abp.Domain.Entities;
using System;

namespace Laboratory.Entities.User
{
    /// <summary>
    /// 账号
    /// </summary>
    public sealed class Account : Entity<Guid>
    {

        #region 属性

        /// <summary>
        /// 昵称
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// 登录Id
        /// </summary>
        public string LoginId { get; private set; }

        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; private set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnabled { get; private set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; private set; }

        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime AddTime { get; private set; }

        /// <summary>
        /// 导航属性 - 角色
        /// </summary>
        public Role Role { get; private set; }

        #endregion


        /// <summary>
        /// 私有构造器 - EF用
        /// </summary>
        private Account()
        {

        }

        /// <summary>
        /// 创建构造器
        /// </summary>
        /// <param name="name">昵称</param>
        /// <param name="loginId">登录Id</param>
        /// <param name="password">密码</param>
        /// <param name="remark">备注</param>
        /// <param name="role">角色</param>
        public Account(string name, string loginId, string password, string remark, Role role) : this()
        {
            this.Id = Guid.NewGuid();
            this.Name = name;
            this.LoginId = loginId;
            this.Password = password;
            this.IsEnabled = true;
            this.Remark = remark;
            this.AddTime = DateTime.Now;
            this.Role = role;
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="name">昵称</param>
        /// <param name="loginId">登录Id</param>
        /// <param name="password">密码</param>
        /// <param name="remark">备注</param>
        /// <param name="role">角色</param>
        public void Update(string name, string loginId, string password, string remark, Role role)
        {
            this.Name = name;
            this.LoginId = loginId;
            this.Password = password;
            this.Remark = remark;
            this.AddTime = DateTime.Now;
            this.Role = role;
        }

        /// <summary>
        /// 设置是否启用
        /// </summary>
        /// <param name="isEnabled">是否启用</param>
        public void SetEnabled(bool isEnabled)
        {
            this.IsEnabled = isEnabled;
        }


    }
}
